//
// Created by Tony on 2024/5/24.
//

#ifndef PARSER_FOR_STMT_H
#define PARSER_FOR_STMT_H

#include "../../AstList.h"
#include "BlockStmt.h"

namespace Parser {

class ForStmt final : public AstList {
    string nodeName;
    shared_ptr<Ast> initExpr;
    shared_ptr<Ast> conditionExpr;
    shared_ptr<Ast> updateExpr;
    shared_ptr<BlockStmt> block;
    shared_ptr<Compiler::SymbolTable> symbolTable;

public:
    ForStmt() : AstList({}) { nodeName = __func__; }

    void setInitExpr(const shared_ptr<Ast>& ast) {
        children.push_back(ast);
        this->initExpr = ast;
    }

    shared_ptr<Ast> getInitExpr() { return initExpr; }

    void setConditionExpr(const shared_ptr<Ast>& ast) {
        children.push_back(ast);
        this->conditionExpr = ast;
    }

    shared_ptr<Ast> getConditionExpr() { return conditionExpr; }

    void setUpdateExpr(const shared_ptr<Ast>& ast) {
        children.push_back(ast);
        this->updateExpr = ast;
    }

    shared_ptr<Ast> getUpdateExpr() { return updateExpr; }

    void setBlock(const shared_ptr<BlockStmt>& block) {
        children.push_back(block);
        this->block = block;
    }

    shared_ptr<BlockStmt> getBlock() { return block; }

    shared_ptr<Compiler::SymbolTable> getSymbolTable() const { return symbolTable; }

    void setSymbolTable(const shared_ptr<Compiler::SymbolTable>& symbolTable) {
        this->symbolTable = symbolTable;
    }

    int32_t accept(Compiler::Visitor* visitor) override;
};

} // namespace Parser

#endif // PARSER_FOR_STMT_H
